package car.aistar.controller;

import car.aistar.dto.XrbRecent;
import car.aistar.entity.CarBrands;
import car.aistar.service.CarBrandsService;
import car.aistar.service.CarOverviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @ClassName SellDealXuController
 * @Description TODO 卖车界面最近成交车辆记录显示
 * @Author laoxu
 * @Date 2020/10/4 11:04
 * Version 1.0
 **/

@Controller
@RequestMapping("/DealXu")
public class SellDealXuController {

    @Autowired
    private CarBrandsService carBrandsService;

    @Autowired
    private CarOverviewService carOverviewService;

    @RequestMapping("/view")
    public String dealView(Model model, String pageNow, String pageSize){
        List<XrbRecent> xrbRecentList = carOverviewService.queryRecent();
//        pageNow = pageNow==null?"1":pageNow;
//        if(pageSize == null  || "-1".equals(pageSize)){
//            pageSize = "5";
//        }
//        PageInfo<XrbRecent> recentPageInfo= carOverviewService.findByPage(pageNow,pageSize);
//        model.addAttribute("page",recentPageInfo);

        model.addAttribute("xrbRecentList",xrbRecentList);

        //查询所有品牌
        CarBrands carBrands = new CarBrands();
        List<CarBrands> carBrandsList = carBrandsService.queryAll(carBrands);
        model.addAttribute("brNames",carBrandsList);
        return "sellCar/sellCar";
    }

}
